package com.askinhand.action;

import javax.annotation.Resource;

import org.apache.struts2.json.annotations.JSON;

import com.askinhand.bean.User;
import com.askinhand.service.IUserService;
import com.opensymphony.xwork2.ActionSupport;

public class UserLoginAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	IUserService userService;
	String strResult;
	String type;
	String userName;
	String password;

	@JSON(serialize=false)
	public IUserService getUserService() {
		return userService;
	}
	
	@Resource
	public void setUserService(IUserService userService) {
		this.userService = userService;
	}
	
	public String getStrResult() {
		return strResult;
	}
	public void setStrResult(String strResult) {
		this.strResult = strResult;
	}
	@JSON(serialize=false)
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@JSON(serialize=false)
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	@JSON(serialize=false)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public String execute(){
		User user = new User();
		user.setType(Integer.parseInt(type));
		user.setUsername(userName);
		user.setPassword(password);
		strResult = userService.login(user);
		System.out.println(type+userName+password);
		return "strResult";
	}
}
